home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / extra / waitmsg.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  818b  |  36 lines

  1.  
  2. /*
  3.  *  WAITMSG.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  *
  9.  *  Wait for a message to be returned, suitable when another task is doing
  10.  *  the ReplyMsg().  NOT suitable for when an interrupt is doing the
  11.  *  ReplyMsg() (must use Disable()/Enable() pair instead of Forbid()/
  12.  *  Permit() if used with interrupts)
  13.  */
  14.  
  15. #include <exec/types.h>
  16. #include <exec/ports.h>
  17. #include <clib/exec_protos.h>
  18. #include <stdio.h>
  19.  
  20. typedef struct Message Message;
  21. typedef struct MsgPort MsgPort;
  22.  
  23. void WaitMsg(Message *);
  24.  
  25. void
  26. WaitMsg(msg)
  27. Message *msg;
  28. {
  29.     while (msg->mn_Node.ln_Type != NT_REPLYMSG)
  30.     Wait(1 << msg->mn_ReplyPort->mp_SigBit);
  31.     Forbid();
  32.     Remove(&msg->mn_Node);
  33.     Permit();
  34. }
  35.  
  36.